using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Order.Dto;
using JTZY.Model.Order;
using JTZY.Service.Order.IOrderService;
using JTZY.Admin.WebApi.Filters;
using JTZY.Service.Order;

//创建时间：2024-11-11
namespace JTZY.Admin.WebApi.Controllers.Order
{
    /// <summary>
    /// 退货明细
    /// </summary>
    [Verify]
    [Route("order/Billaftersaledetail")]
    public class BillaftersaledetailController : BaseController
    {
        /// <summary>
        /// 退货明细接口
        /// </summary>
        private readonly IBillaftersaledetailService _BillaftersaledetailService;

        public BillaftersaledetailController(IBillaftersaledetailService BillaftersaledetailService)
        {
            _BillaftersaledetailService = BillaftersaledetailService;
        }

        /// <summary>
        /// 查询退货明细列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "billaftersaledetail:list")]
        public IActionResult QueryBillaftersaledetail([FromQuery] BillaftersaledetailQueryDto parm)
        {
            var response = _BillaftersaledetailService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 退货明细
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpPost("getdeatils")]
        [ActionPermissionFilter(Permission = "billaftersaledetail:list")]
        public IActionResult GetExchangedetails([FromBody] QueryDetailsDto parm)
        {
            var response = _BillaftersaledetailService.GetDetails(parm);
            return SUCCESS(response);
        }

        /// <summary>
        /// 查询退货明细详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "billaftersaledetail:query")]
        public IActionResult GetBillaftersaledetail(long Id)
        {
            var response = _BillaftersaledetailService.GetInfo(Id);
            
            var info = response.Adapt<BillaftersaledetailDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加退货明细
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "billaftersaledetail:add")]
        [Log(Title = "退货明细", BusinessType = BusinessType.INSERT)]
        public IActionResult AddBillaftersaledetail([FromBody] BillaftersaledetailDto parm)
        {
            var modal = parm.Adapt<Billaftersaledetail>().ToCreate(HttpContext);

            var response = _BillaftersaledetailService.AddBillaftersaledetail(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新退货明细
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "billaftersaledetail:edit")]
        [Log(Title = "退货明细", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateBillaftersaledetail([FromBody] BillaftersaledetailDto parm)
        {
            var modal = parm.Adapt<Billaftersaledetail>().ToUpdate(HttpContext);
            var response = _BillaftersaledetailService.UpdateBillaftersaledetail(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除退货明细
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "billaftersaledetail:delete")]
        [Log(Title = "退货明细", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteBillaftersaledetail([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_BillaftersaledetailService.Delete(idArr));
        }


    }
}